﻿using mscook.core.domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Linq;
namespace mscook.core.repositories
{
    public class HotelRepository : Repository<Hotel>, IHotelRepository
    {
        public IList<Hotel> GetLimitPartner(int start, int limit)
        {
            var query = (from x in this.Session.Query<Hotel>() select x)
            .Where(o => o.IsDelete == false
                &&o.IsPartner==true
                ).OrderByDescending(o=>o.EntityIndex).OrderByDescending(o=>o.CreateTime);
            return query.Skip(start).Take(limit).ToList();
        }

        public IList<Hotel> SelectPageList(int start, int limit, out long total, string HotelName)
        {
            var query = (from x in this.Session.Query<Hotel>() select x)
            .Where(o => o.IsDelete == false
                && (string.IsNullOrEmpty(HotelName)||o.Name.Contains(HotelName))
                ).OrderByDescending(o => o.EntityIndex).OrderByDescending(o => o.CreateTime);
            total = query.Count();
            return query.Skip(start).Take(limit).ToList();
        }

        public IList<Hotel> SelectBottomHotelList(int size)
        {
            var query = (from x in this.Session.Query<Hotel>() select x).Where(o => o.IsDelete == false
                && o.IsShowOnBottom == true);
            return query.Take(size).ToList();
        }

       
    }
}
